﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace msdcp
{
    public partial class SelectPortDialog : Form
    {
        private string[] portNames;
        private string selectedPort;

        public string[] PortNames
        {
            get { return portNames; }
            set { portNames = value; }
        }

        public string SelectedPort
        {
            get { return selectedPort; }
        }

        public SelectPortDialog(string[] ports)
        {
            InitializeComponent();

            portNames = ports;
            selectedPort = ports[0];
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            selectedPort = comboPorts.SelectedItem.ToString();
        }

        private void SelectPortDialog_Load(object sender, EventArgs e)
        {
            FillComboBox();
        }

        private void FillComboBox()
        {
            comboPorts.Items.AddRange(portNames);
            comboPorts.SelectedIndex = 0;
        }

        private void SelectPortDialog_Shown(object sender, EventArgs e)
        {
            this.Activate();
        }
    }
}
